$(function(){
    //alert("aaaa");
    var userId = sessionStorage.getItem('userId');
    console.log(userId);
    function fmoney(s, n)
    {
        n = n > 0 && n <= 20 ? n : 2;
        s = parseFloat((s + '').replace(/[^\d\.-]/g, '')).toFixed(n) + '';
        var l = s.split('.') [0].split('').reverse(),
            r = s.split('.') [1];
        var  t = '';
        for (var i = 0; i < l.length; i++)
        {
            t += l[i] + ((i + 1) % 3 == 0 && (i + 1) != l.length ? ',' : '');
        }
        return t.split('').reverse().join('');
    }
    //一、默认显示
    var modelSend={
        "model":'index_account_detail_data_pages',
        "condition":{},
        "item":{
            "current_month":[2],
            "sale_amount":["1","2","3"]
        }
    };
    //渲染复购次数
    $.ajax({
        url: "https://up-bi.pec.com.cn/data-center/indexboard/getIndexBoardInfo?token="+userId,
        type: "POST",
        headers:{"marker":userId},
        data:{"paramData":JSON.stringify(modelSend)},
        success:function(data){
            console.log(data)
            $(".ui-btn").after('<h2>'+data.data[11].timeInfo+'月累计交易额</h2>');
            var data=data.data;
            console.log(data);
            var str="";
            for (var i=0; i<data.length-3; i++){
                console.log(data[i]);
                str+='<li>' +
                    '<div class="left">' +
                    '<p>'+data[i].lable+'</p>' +
                    '<span>'+fmoney(data[i].tradeAccumuAmount,2)+'</span>' +
                    '</div>' +
                    '<div class="right">' +
                    '<p>支付宝: '+fmoney(data[i].tradeAccumuAmountAlipay,2)+'</p>' +
                    '<p>微信: '+fmoney(data[i].tradeAccumuAmountWechat,2)+'</p>' +
                    '<p>现金: '+fmoney(data[i].tradeAccumuAmountCash,2)+'</p>' +
                    '</div>' +
                    '</li>'
            }

            $(".main_list").html(str)


        }
    })

})


